Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Controlling Volume Levels

You can use the GetSysBeepVolume and SetSysBeepVolume functions to get and set the volume level of the system alert sound. You can use GetDefaultOutputVolume and SetDefaultOutputVolume to get and set the default output volume for a particular output device.

These four functions are available only in Sound Manager version 3.0 and later.

With all of these functions, you specify a volume with a 16-bit value, where 0 represents no volume (that is, silence) and 256 (hexadecimal $0100) represents full volume. The right and left volumes of a stereo sound are encoded as the high word and the low word, respectively, of a 32-bit value. Moreover, it's possible to overdrive a particular volume level if you need to amplify a low signal. For example, the long word $02000200 specifies a volume level of twice full volume on both the left and right channels of a stereo sound.

In addition to the four functions described in this section, Sound Manager version 3.0 introduces two new sound commands, getVolumeCmd and volumeCmd , that you can use to get and set the volume of a particular sound channel. See [link] for details on these two sound commands; see "Managing Sound Volumes" for a code listing that uses the volumeCmd command.

GetSysBeepVolume

You can use the GetSysBeepVolume function to determine the current volume of the system alert sound.

FUNCTION GetSysBeepVolume (VAR level: LongInt): OSErr;
level
On exit, the current volume level of the system alert sound.

DESCRIPTION

The GetSysBeepVolume function returns, in the level parameter, the current volume level of the system alert sound. The values returned in the high and low words of the level parameter range from 0 (silence) to $0100 (full volume).

SPECIAL CONSIDERATIONS

The GetSysBeepVolume function is available only in versions 3.0 and later of the Sound Manager. You can call this function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the GetSysBeepVolume function are

Trap macro

Selector

_SoundDispatch

$02240024

RESULT CODES

noErr

0

No error

SetSysBeepVolume

You can use the SetSysBeepVolume function to set the current volume of the system alert sound.

FUNCTION SetSysBeepVolume (level: LongInt): OSErr;
level
The desired volume level of the system alert sound.

DESCRIPTION

The SetSysBeepVolume function sets the current volume level of the system alert sound. The values you can specify in the high and low words of the level parameter range from 0 (silence) to $0100 (full volume). Any calls to the SysBeep procedure use the volume set by the most recent call to SetSysBeepVolume .

SPECIAL CONSIDERATIONS

The SetSysBeepVolume function is available only in versions 3.0 and later of the Sound Manager. You can call this function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SetSysBeepVolume function are

Trap macro

Selector

_SoundDispatch

$02280024

RESULT CODES

noErr

0

No error

GetDefaultOutputVolume

You can use the GetDefaultOutputVolume function to determine the default volume of a sound output device.

FUNCTION GetDefaultOutputVolume (VAR level: LongInt): OSErr;
level
On exit, the default volume level of a sound output device.

DESCRIPTION

The GetDefaultOutputVolume function returns, in the level parameter, the default volume of a sound output device. The values returned in the high and low words of the level parameter range from 0 (silence) to $0100 (full volume).

SPECIAL CONSIDERATIONS

The GetDefaultOutputVolume function is available only in versions 3.0 and later of the Sound Manager. You can call this function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the GetDefaultOutputVolume function are

Trap macro

Selector

_SoundDispatch

$022C0024

RESULT CODES

noErr

0

No error

SetDefaultOutputVolume

You can use the SetDefaultOutputVolume function to set the default volume of a sound output device.

FUNCTION SetDefaultOutputVolume (level: LongInt): OSErr;
level
The desired default volume level of a sound output device.

DESCRIPTION

The SetDefaultOutputVolume function sets the default volume of a sound output device. The values you can specify in the high and low words of the level parameter range from 0 (silence) to $0100 (full volume).

SPECIAL CONSIDERATIONS

The SetDefaultOutputVolume function is available only in versions 3.0 and later of the Sound Manager. You can call this function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SetDefaultOutputVolume function are

Trap macro

Selector

_SoundDispatch

$02300024

RESULT CODES

noErr

0

No error


© 1999 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |